package tx.bj12320.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.model.enums.BooleanEnum;
import tx.bj12320.model.enums.SysUserTypeEnum;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


@Entity
@Table(name = "BJ12320_ORG_INFO")
public class OrgInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "单位信息";
	public static final String ALIAS_ORG_INFO_ID = "orgInfoId";
	public static final String ALIAS_ORG_NAME = "单位名称";
	public static final String ALIAS_ZONE_NAME = "辖区名称";
	public static final String ALIAS_ZONE_DD_VALUE = "辖区值";
	public static final String ALIAS_ORDER_INDEX = "顺序";
	public static final String ALIAS_ORG_LEVEL = "级别";
	public static final String ALIAS_SYS_USER_TYPE = "所属系统类别组";
	public static final String ALIAS_PARENT_ORG_INFO_ID = "父单位ID";
	public static final String ALIAS_ORG_CODE = "单位编码";
	public static final String ALIAS_PARENT_ORG_CODE = "父单位编码";

	//date formats


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * orgInfoId       db_column: ORG_INFO_ID
     */

	private Long orgInfoId;
    /**
     * 单位名称       db_column: ORG_NAME
     */
	@Length(max=200)
	private java.lang.String orgName;
    /**
     * 辖区名称       db_column: ZONE_NAME
     */
	@Length(max=200)
	private java.lang.String zoneName;
    /**
     * 辖区值       db_column: ZONE_DD_VALUE
     */
	@Length(max=200)
	private java.lang.String zoneDdValue;
    /**
     * 顺序       db_column: ORDER_INDEX
     */

	private Long orderIndex;
    /**
     * 级别       db_column: ORG_LEVEL
     */

	private Long orgLevel;
    /**
     * 所属系统类别组       db_column: SYS_USER_TYPE
     */
	@Length(max=200)
	private java.lang.String sysUserType;
    /**
     * 父单位ID       db_column: PARENT_ORG_INFO_ID
     */

	private Long parentOrgInfoId;
    /**
     * 单位编码       db_column: ORG_CODE
     */
	@Length(max=200)
	private java.lang.String orgCode;
    /**
     * 父单位编码       db_column: PARENT_ORG_CODE
     */
	@Length(max=200)
	private java.lang.String parentOrgCode;
	//columns END


	public OrgInfo(){
	}

	public OrgInfo(
		Long orgInfoId
	){
		this.orgInfoId = orgInfoId;
	}



	public void setOrgInfoId(Long value) {
		this.orgInfoId = value;
	}

	@Id	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BJ12320_ORG_INFO_SEQU")
    @SequenceGenerator(name="BJ12320_ORG_INFO_SEQU",allocationSize=1,initialValue=1, sequenceName="BJ12320_ORG_INFO_SEQU")
	@Column(name = "ORG_INFO_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 22)
	public Long getOrgInfoId() {
		return this.orgInfoId;
	}

	@Column(name = "ORG_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getOrgName() {
		return this.orgName;
	}

	public void setOrgName(java.lang.String value) {
		this.orgName = value;
	}

	@Column(name = "ZONE_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getZoneName() {
		return this.zoneName;
	}

	public void setZoneName(java.lang.String value) {
		this.zoneName = value;
	}

	@Column(name = "ZONE_DD_VALUE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getZoneDdValue() {
		return this.zoneDdValue;
	}

	public void setZoneDdValue(java.lang.String value) {
		this.zoneDdValue = value;
	}

	@Column(name = "ORDER_INDEX", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getOrderIndex() {
		return this.orderIndex;
	}

	public void setOrderIndex(Long value) {
		this.orderIndex = value;
	}

	@Column(name = "ORG_LEVEL", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getOrgLevel() {
		return this.orgLevel;
	}

	public void setOrgLevel(Long value) {
		this.orgLevel = value;
	}

	@Column(name = "SYS_USER_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getSysUserType() {
		return this.sysUserType;
	}

	public void setSysUserType(java.lang.String value) {
		this.sysUserType = value;
	}

	@Column(name = "PARENT_ORG_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 22)
	public Long getParentOrgInfoId() {
		return this.parentOrgInfoId;
	}

	public void setParentOrgInfoId(Long value) {
		this.parentOrgInfoId = value;
	}

	@Column(name = "ORG_CODE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getOrgCode() {
		return this.orgCode;
	}

	public void setOrgCode(java.lang.String value) {
		this.orgCode = value;
	}

	@Column(name = "PARENT_ORG_CODE", unique = false, nullable = true, insertable = true, updatable = true, length = 200)
	public java.lang.String getParentOrgCode() {
		return this.parentOrgCode;
	}

	public void setParentOrgCode(java.lang.String value) {
		this.parentOrgCode = value;
	}


	private Set tszbProcessInfos = new HashSet(0);
	public void setTszbProcessInfos(Set<TszbProcessInfo> tszbProcessInfo){
		this.tszbProcessInfos = tszbProcessInfo;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "orgInfo")
	public Set<TszbProcessInfo> getTszbProcessInfos() {
		return tszbProcessInfos;
	}

	private Set userInfos = new HashSet(0);
	public void setUserInfos(Set<UserInfo> userInfo){
		this.userInfos = userInfo;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "orgInfo")
	public Set<UserInfo> getUserInfos() {
		return userInfos;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("OrgInfoId",getOrgInfoId())
			.append("OrgName",getOrgName())
			.append("ZoneName",getZoneName())
			.append("ZoneDdValue",getZoneDdValue())
			.append("OrderIndex",getOrderIndex())
			.append("OrgLevel",getOrgLevel())
			.append("SysUserType",getSysUserType())
			.append("ParentOrgInfoId",getParentOrgInfoId())
			.append("OrgCode",getOrgCode())
			.append("ParentOrgCode",getParentOrgCode())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getOrgInfoId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof OrgInfo == false) return false;
		if(this == obj) return true;
		OrgInfo other = (OrgInfo)obj;
		return new EqualsBuilder()
			.append(getOrgInfoId(),other.getOrgInfoId())
			.isEquals();
	}
	@Transient
	public java.lang.String getSysUserTypeString() {
		return sysUserType==null?"":SysUserTypeEnum.getByCode(sysUserType).getDesc();
	}
}

